package com.example.dao;

import com.example.entity.Subject;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
//@Repository
public interface SubjectDao {

    /**
     * 分页查询
     * @param currentPage  当前页
     * @param pageSize     当前页条数
     * @return
     */
    @Select("select * from subject limit #{currentPage}, #{pageSize}")
    public List<Subject> getPage(@Param("currentPage") int currentPage, @Param("pageSize")int pageSize);

    /**
     * 查询总记录数
     * @return
     */
    @Select("select count(*) from subject")
    public int getTotalCount();


    @Insert("insert into subject(name,subject_type,credit,examination_type) values(#{name},#{subjectType},#{credit},#{examinationType})")
    public int add(Subject subject);

    @Delete("delete from subject where id=#{id}")
    public Boolean deleteById(@Param("id") Integer id);

    @Update("update subject set name=#{name},subject_type=#{subjectType},credit=#{credit},examination_type=#{examinationType} where id=#{id}")
    public int update(Subject subject) ;
}
